
component output="false" extends="AbsService" accessors="true" {

	// Delegate
	property name="SkinDelegate" type="it.millemultimedia.easyBlog.delegate.SkinDelegate";

	public it.millemultimedia.easyBlog.service.SkinService function init(){
		
		return this;
	}
	
	public it.millemultimedia.easyBlog.validator.SkinValidator function getValidator(){
		
		return getSkinDelegate().getValidator();
	}
	
	public it.millemultimedia.easyBlog.model.Skin function new(){
		
		return getSkinDelegate().createInstance();
	}
	
	public it.millemultimedia.easyBlog.model.Skin function getSkin( required Any Skin ){
		
		return getSkinDelegate().read( arguments.Skin );
	}
	
	public it.millemultimedia.easyBlog.model.Skin[] function getSkins( required Any Skin ){
		
		return getSkinDelegate().list( arguments.Skin );
	}
	
	public boolean function skinExists( required Any Skin ){
		var result = getSkinDelegate().list( arguments.Skin );
		
		return arrayLen( result ) gt 0;
	}
	
	public void function saveSkin( required Any Skin ){
	
		transaction{
		
			try{
				
				
				if( arguments.Skin.getidSkin()  eq 0 ){
				
					this.createSkin( arguments.Skin );
				
				}else if( arguments.Skin.getIdSkin() gt 0 ){
				
					this.updateSkin( arguments.Skin );
				
				}else{
				
					throw( message="Skin id property have undefined value." );
				
				}
			
			}catch( except Any ){
			
				transaction action="rollback";
				
				throw( except.message );
			
			}
		
		}
		
	}
	
	public void function createSkin( required Any Skin ){
	
		transaction{
		
			try{
			
				getSkinDelegate().create( arguments.Skin );
			
			}catch( except Any ){
			
				transaction action="rollback";
				
				throw( except.message );
			
			}
		
		}
		
	}
	
	public void function updateSkin( required Any Skin ){
	
		transaction{
		
			try{
			
				getSkinDelegate().update( arguments.Skin );
			
			}catch( except Any ){
			
				transaction action="rollback";
				
				throw( except.message );
			
			}
		
		}
		
	}
	
	public void function deleteSkin( required Any Skin ){
	
		transaction{
		
			try{
			
				getSkinDelegate().delete( arguments.Skin );
				
			
			}catch( except Any ){
			
				transaction action="rollback";
				
				throw( except.message );
							
			}
			
		}
		
	}
	
}
